package com.example.k.littletag.utils;

import android.util.Log;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Kong on 2015/10/2.
 */
public class Utils {
    private static long[] time = new long[3];

    public static long[] timeBetween(int[] date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String systemTime = (sdf.format(new Date())).toString();
        String aimTime = date[0] + "-" + date[1] + "-" + date[2] + " " + date[3] + ":" + date[4] + ":" + date[5];

        Log.d("time_return sys_aim", systemTime+"  "+aimTime);

        try {
            Date begin = sdf.parse(systemTime);
            Date end = sdf.parse(aimTime);

            long between = (end.getTime() - begin.getTime()) / 1000;//转换成秒

            long day = between / (24 * 3600);
            long hour = between % (24 * 3600) / 3600;
            long minute = between % 3600 / 60;

            time[0] = day;
            time[1] = hour;

            time[2] = minute;//分钟存在误差


        } catch (ParseException e) {
            e.printStackTrace();
        }

        return time;
    }

}
